Array.prototype._reduce = function (callback, initialValue) {
  if (this === null) {
    throw new TypeError(`Array.prototype._reduce called on null or undefined`)
  }
  if (typeof callback !== 'function') throw new TypeError(`${callback} is not a function`)
  var arr = Object(this)
  var base = typeof initialValue === 'undefined' ? arr[0] : initialValue;
  var startReduce = typeof initialValue === 'undefined' ? 1 : 0;
  Array.prototype.slice.call(arr, startReduce)
  for (var i = startReduce; i < arr.length; i++) {
    base = callback(base, arr[i], i + startReduce, this)
  }
  return base;
}

const add = [1, 2, 3, 4]._reduce((a, b) => a + b, 0)
console.log(add)